﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _012_Dictionary字典
{
    class Program
    {
        static Dictionary<string, string> dict = new Dictionary<string, string>();
        static void Main(string[] args)
        {
            dict.Add("baidu.com", "220.181.38.251");
            dict.Add("gdmec.com", "58.248.104.1");
            dict.Add("FTP", "10.1.51.100");


            dict.Remove("gdmec.com");
            //安全
            if (dict.ContainsKey("gdmec.com"))
            {
                dict["gdmec.cn"] = "192.168.1.1";
            }
            else
            {
                dict.Add("gdmec.cn", "192.168.1.1");
            }

            //foreach遍历
            foreach(var key in dict.Keys)
            {
                Console.WriteLine(key + "的IP是" + dict[key]);
            }

            foreach (var key in dict.Keys)
            {
                GetIP(key);
            }


            //另外一种配置
            Dictionary<string, int> dict2 = new Dictionary<string, int>();
            dict2.Add("EnemyCount", 2);
            dict2.Add("SpuerEnemyCount", 4);

            Console.ReadKey();
            
        }

        static public void GetIP(string url)
        {
            Console.WriteLine(url + "的IP是：" + dict[url]);
        }
    }
}
